package com.second.app.thread.线程基础.day07.线程通信.管道;

import java.io.IOException;
import java.io.PipedInputStream;

/**
 * @Author GYZ
 * @Date 2023/11/29
 * <pre>
 *
 * </pre>
 */
public class ReadData {
    public void readMethod(PipedInputStream input){
        try {
            System.out.println("read :");
            byte[]byteArray = new byte[20];
            int readLength = input.read(byteArray);
            while (readLength!=-1){
                String newData = new String(byteArray,0,readLength);
                System.out.println(newData);
                readLength = input.read(byteArray);
            }
            System.out.println();
            input.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
